/* 
接口请求函数模块
*/

import request from "./request";

//登录
export const reqLogin =(username,pwd)=> request({
    url: '/admin/login',
    method: 'POST',
    data:{username,pwd}
})

//获取用户信息
export const reqInfo = () => request('/admin/info')

//退出登录
export const reqLogout = () => request('/admin/logout')

//添加用户
export const reqAddUser = (user) => request({
    url: '/admin/user',
    method: 'POST',
    data:user
})

//获取用户分页列表
export const reqUserList = (page,limit) => request({
    url: `/admin/user/${page}/${limit}`,
    method: 'GET'
})

//获取用户
export const reqGetUser = (id) => request({
    url: '/admin/user',
    method: 'GET',
    params: {
        id
    }
})

//更新用户
export const reqUpdateUser = (formData)  => request({
    url: '/admin/user',
    method: 'PUT',
    data:formData // 后台formidable来解析这个数据
})

//删除用户
export const reqDeleteUser = (id) => ({
    url: `/admin/user/${id}`,
    method:'DELETE'
})


/* 
接口请求函数模块对象式写法
*/
/*
import request from './request'

//登录
export const reqLogin = (username, pwd) => request.post('/admin/login', { username, pwd })

//获取用户信息
export const reqInfo = () => request.get('/admin/info')

//退出登录
export const reqLogout = () => request.get('/admin/logout')

//添加用户
export const reqAddUser = (user) => request.post('/admin/user', user)

//获取用户分页列表
export const reqUserList = (page, limit) = request.get(`/admin/user/${page}/${limit}`)

//获取用户
export const reqGetUser = (user) => request.get(`/admin/user`, { params: { id } })

//更新用户
export const reqUpdateUser = (formData) => request.put('/admin/user', formData)

//删除用户
export const reqDeleteUser = (id) => request.delete(`/admin/user/${id}`)
*/